package com.ciwong.demoenglish.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.ciwong.epaper.modules.otherlogin.LoginController;
import com.ciwong.epaper.modules.share.WxShareHelper;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;

/**
 * 微信登录，分享  结果回调类 Created by res-dlzhou on 2015/8/25.
 */
public class WXEntryActivity extends Activity implements IWXAPIEventHandler
{
    private LoginController mLoginController;
    private WxShareHelper mShareHelper;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        mShareHelper=WxShareHelper.getInstance();
        if(null!=getIntent()||null!=mShareHelper){
            mShareHelper.getmShareIWXAPI().handleIntent(getIntent(),this);
        }
    }

    @Override
    protected void onNewIntent(Intent intent)
    {
        setIntent(intent);
        mShareHelper.getmShareIWXAPI().handleIntent(getIntent(),this);

    }

    @Override
    public void onReq(BaseReq baseReq)
    {
        System.out.println("Share==>> " + "WXEntryActivity onReq：" + baseReq.openId+baseReq.getType());
        mShareHelper.dealWithWeiXin0nResp(baseReq);
    }

    @Override
    public void onResp(BaseResp baseResp)
    {
        //mLoginController.dealWithWeixinOnResp(baseResp);
        System.out.println("Share==>> " + "WXEntryActivity onResp：" + baseResp.errStr+"\n" + baseResp.openId+"\n"
                +baseResp.errCode+"\n"+baseResp.transaction+"\n"+baseResp.getType());
        mShareHelper.dealWithWeixinOnResp(baseResp);
        finish();
    }
}
